﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CloudSoft.Extensions;

namespace ERPStore.Exporter.Models.LeadSources
{
	public class KelkooSource : ERPStore.Models.LeadSourceBase
	{
		public override string Id
		{
			get { return "67171C7D-1F39-41DE-9C33-445E34B8622E"; }
		}

		public override string Name
		{
			get { return "Kelkoo"; }
		}

		public override string Description
		{
			get { return "Comparateur de prix Kelkoo"; }
		}

		public override string TrackSourceId
		{
			get { return "kelkoo"; }
		}

		public override string Medium
		{
			get { return "cpc"; }
		}

		public override ERPStore.Models.LeadSourceType LeadSourceType
		{
			get { return ERPStore.Models.LeadSourceType.PriceComparator; }
		}

		public override bool Match(Uri sourceUri, Uri landingUri, out string keywords, out string subHost, out decimal amount)
		{
			keywords = null;
			subHost = null;
			amount = 0.17m;
			var landingPrms = landingUri.GetParameters();
			if (landingPrms.AllKeys.Contains("gclid")) // Lien sponso 
			{
				return false;
			}
			else if (landingPrms.AllKeys.Contains("estid"))
			{
				var estid = landingPrms["estid"];
				if (estid.Equals("kelkoo", StringComparison.InvariantCultureIgnoreCase))
				{
					subHost = "No referer";
					return true;
				}
			}
			else if (sourceUri.Host.ToLower().IndexOf("kelkoo") != -1)
			{
				return true;
			}

			return false;
		}

	}
}
